<?php         
$db = new Database;
$auth = Auth::getAuth('current_user');
$user_id = $auth['id'];
$company_id = $auth['company_id'];
?>
                <div class="row-fluid" >
                    <div class="span5" style="padding: 10px;min-height: 430px;">
                        <div class="tabbable"> <!-- Only required for left/right tabs -->
                            <ul class="nav nav-tabs fontTahoma">
                              <li class="addfield form_s field_s active"><a href="#tab1" data-toggle="tab">Add Fields</a></li>
                              <li class="fieldsettings form_s field_s"><a href="#tab2" data-toggle="tab">Field Settings</a></li>
                              <li class="formsetting form_s "><a href="#tab3" data-toggle="tab">Form Settings</a></li>
                              <li class="workflowSettings field_s "><a href="#tab4" data-toggle="tab">Work Flow</a></li>
                              <!--li><a href="#tab4" data-toggle="tab">TBA</a></li-->
                            </ul>
                            <div class="tab-content">
                              <div class="tab-pane active" id="tab1">
                                <!--Object to be append-->
                                    <p class="fontGray">Html Objects</p>
                                    <?php
                                    $db = new Database();
                                    $query = $db->query("SELECT * from tbdefault_fields where fieldClassification=1 AND is_active='1'","array");
                                    $start = 1;
                                    foreach($query as $row){
                                        if($row['id']%2==1){
                                            echo "<p>";
                                        }
                                        if($row['icon']!="" && $row['btnType']==""){
                                        ?>
                                            <a title="<?php echo $row['field'];?>" class="btn btn-medium buttonLeft objects fontTahoma" ftc="<?php echo $row['ftc']; ?>" ><i class="<?php echo $row['icon']; ?> pull-left"></i> <?php echo $row['field']; ?></a>
                                        <?php
                                        }else{
                                        ?>
                                            <a title="<?php echo $row['field'];?>" class="btn btn-medium buttonLeft fontTahoma <?php echo $row['btnType']; ?> pull-left objects" ftc="<?php echo $row['ftc']; ?>"> <?php echo $row['field']; ?></a>
                                        <?php   
                                        }
                                        if($row['id']%2==0){
                                            echo "</p>";
                                        }
                                        $start++;
                                    }
                                    ?>
                                    <br /><br />
                                    <p class="fontGray" >Customize Objects</p>
                                    <?php
                                    $query = $db->query("SELECT * from tbdefault_fields where fieldClassification=2 AND is_active='1'","array");
                                    foreach($query as $row){
                                        if($row['id']%2==0){
                                            ?>
                                            <p>
                                            <?php
                                        }
                                        if($row['icon']!="" && $row['btnType']==""){
                                        ?>
                                            <a title="<?php echo $row['field'];?>" class="btn btn-medium buttonLeft objects fontTahoma" ftc="<?php echo $row['ftc']; ?>" ><i class="<?php echo $row['icon']; ?> pull-left"></i> <?php echo $row['field']; ?></a>
                                        <?php
                                        }else{
                                        ?>
                                            <a title="<?php echo $row['field'];?>" class="btn btn-medium buttonLeft fontTahoma <?php echo $row['btnType']; ?> pull-left objects" ftc="<?php echo $row['ftc']; ?>"> <?php echo $row['field']; ?></a>
                                        <?php
                                        }
                                        if($row['id']%2==1){
                                            ?>
                                            </p>
                                            <?php
                                        }
                                    }
                                    ?>
                              </div>
                              <div class="tab-pane field_settings" id="tab2">
                                <h6>No Object is selected </h6>
                              </div>
                              <div class="tab-pane " id="tab3">
                                <label id='labelObject' class="fontGray">Form Name:</label>
                                    <input type="text" class="formName" value="Untitled Form"/>
                                <label id='labelObject' class="fontGray">Description:</label>
                                    <textarea class="formDesc">This is my form. Please fill it out. It's awesome!</textarea>                                       
                                <label id='labelObject' class="fontGray">Label Placement:</label>
                                    <select class="select large" id="formLabelAlign" autocomplete="off" <!--onchange="updateForm($F(this), 'LabelAlign')"-->>
                                        <option value="left">Left Aligned</option>
                                        <option value="center">Center Aligned</option>
                                        <option value="right">Right Aligned</option>
                                    </select>
                                <label id='labelObject' class="fontGray">Status of request if the approver is updated:</label>
                                <select class="select confRequest" id="" autocomplete="off" <!--onchange="updateForm($F(this), 'LabelAlign')"-->>
                                    <option value="0">--Select--</option>
                                    <option value="1">Back to the First Approver</option>
                                    <option value="2">Jump to the Next Approver</option>
                                </select>
                                <label id='labelObject' class="fontGray">Users:</label>
                                <label class="checkbox"><input type="checkbox" class="usersForm allUsers" value="allUsers"/>All Users</label>
                                <label><span class="icon-plus formUser" rel="getDepartmentFF" id="getDepartmentFF"></span> Department</label>
                                <span class="span getDepartmentFF" style="display: none;">
                                    <?php
                                    $getDepartment = $db->query("SELECT * FROM tborgchart o LEFT JOIN tborgchartobjects oo on o.id=oo.orgChart_id WHERE o.status=1 and o.company_id='$company_id'","array");
                                    foreach($getDepartment as $setDepartment){
                                        ?>
                                        <label class="checkbox"><input type="checkbox"  class="usersForm usersType usersDept" value="<?php echo $setDepartment['role'] ?>"/><?php echo $setDepartment['role'] ?></label>
                                        <?php
                                    }
                                    ?>
                                </span>
                                <label><span class="icon-plus formUser" rel="getPositionFF" id="getPositionFF"></span> Position</label>
                                <span class="span getPositionFF" style="display: none;">
                                    <?php
                                    $getPosition = $db->query("SELECT * FROM tbposition WHERE company_id='$company_id' and is_active=1","array");
                                    foreach($getPosition as $setPosition){
                                        ?>
                                        <label class="checkbox"><input type="checkbox" class="usersForm usersType" value="<?php echo "pos_".$setPosition['id'] ?>"/><?php echo $setPosition['position'] ?></label>
                                        <?php
                                    }
                                    ?>
                                </span>
                                <label><span class="icon-plus formUser" rel="getUserFF" id="getUserFF"></span> User</label>
                                <span class="span getUserFF" style="display: none;">
                                    <?php
                                    $getUsers = $db->query("SELECT * from tbuser where status = 1 and company_id = '$company_id' and is_active = 1","array");
                                    foreach($getUsers as $setUsers){
                                        ?>
                                        <label class="checkbox"><input type="checkbox"  class="usersForm usersType" value="<?php echo $setUsers['id'] ?>"/><?php echo setName($setUsers['firstname'],"",$setUsers['lastname']); ?></label>
                                        <?php
                                    }
                                    ?>
                                </span>
                              </div>
                              <div class="tab-pane" id="tab4" style="min-height: 500px">
                                <h4>Work Flow Objects</h4>
                                <label>Approver Type:</label>
                                <select class="approverTypeWorkflow" style="margin-bottom: 0px;margin-right: 3px">
                                    <option value="0">--Select--</option>
                                    <option value="1">Group Position</option>
                                    <option value="2">Position in the Company</option>
                                    <option value="3">Specific User</option>
                                </select>
                                <br /><br />
                                <label>Approver:</label>
                                <select class="approverWorkflow" style="">
                                    <option value="0">--Select--</option>
                                </select>
                                <br /><br />
                                <label>Approver Status:</label>
                                <select class="approverWorkflowStatus" style="">
                                    <option value="1">For Review</option>
                                    <option value="2">Approver</option>
                                </select>
                                <!--br /><br />
                                <label>Status:</label>
                                <select class="statusWorkflow" style="">
                                    <option value="0">--Select Status--</option>
                                </select-->
                                <br />
                                
                                <input type="button" class="btn shapes" id="worklow" rel="workflow" value="Add">
                                <!--div class="conditionDiv">
                                    <label>Fields</label>
                                    <select class="formLabels" style="">
                                        <option>--Select Field--</option>
                                    </select>
                                </div>
                                <input type="button" class="btn shapes" id="worklow" rel="workflowCondition" value="Add Condition"-->
                              </div>
                            </div>
                        </div>
                    </div>
                        
                    <div class="span7 forForm" style="padding: 5px;min-height: 450px; margin-top: 10px;background-color: #FFF; margin-left: 0px; border: 1px solid #ddd;">
                            <!-- Contents here -->
                            <a href="#tab3" data-toggle="tab" class="formtitleHolder">
                                <span id='head' class='span12 setObjectForm borderDashed'>
                                    <h4 style="cursor: pointer;" class="formTitleText" align="leftLabel">Untitled Form</h4>
                                    <p style="color: #555;" class="formDescText">This is my form. Please fill it out. It's awesome!</p>
                                </span>
                            </a>
                            <div class="mainContent" id="drag">
                                <br />
                                
                            </div>
                    </div>
                    <div class="main_container" style="display: none;width: 55%;float: right;margin-top: 40px;background-color: #FFF">
                        <span class="actionHolder">
                            <!--img src="/images/flowchart/decision-symbol.png" id="terminator-symbol" rel="decision" height="15" width="20" title="Desision" class="actionBtn shapes"-->
                            <img src="/images/flowchart/end.png" id="endOfDiagram" rel="endOfDiagram" height="20" width="25" title="End Of Diagram" class="actionBtn shapes">
                            <img src="/images/flowchart/new_diagram.png" id="terminator-symbol" rel="newDiagram" height="15" width="20" title="New Worflow" class="actionBtn">
                            <img src="/images/flowchart/del_node.png" id="delete" rel="delete" height="15" width="20" title="Delete node" class="actionBtn">
                            <img src="/images/flowchart/print_diagram.png" id="printDiagram" rel="print" height="20" width="25" title="Print Diagram" class="actionBtn">
                            <img src="/images/flowchart/zoom_in_diagram.png" id="zoomInDiagram" rel="zIn" height="15" width="20" title="Zoom In" class="actionBtn">
                            <img src="/images/flowchart/zoom_out_diagram.png" id="zoomOutDiagram" rel="zOut" height="15" width="20" title="Zoom Out" class="actionBtn">
                        </span>
                        <div class="flow_content">
                            <!--Start-->
                            <span class="appendShapes workflowObjects appendObjects" node-type="start" diagram-type="workflow" rel="notAllowed" id="flowspan_1_worklow" style="left: 0px;top: 0px">
                            <span id="spanText_1" class="textHandle" style="cursor:pointer;position: absolute;margin: 12px;width: 60px;text-align: center;font-size: large">START</span>
                              <span id="flow_1_worklow" rel="1" class="fl_shapes"></span>
                              <span style="position:absolute" class="shapeSideButton_holder">
                                  <span style="color:red;position:absolute;margin-left:-10px;width:10px;height:10px;padding-left:5px;margin-top:12px;background-color:black" class="right connector"  id="right_1_worklow"></span>
                              </span>
                            </span>
                        </div>
                    </div>
                    <div class="span4 offset7" style="margin-top: 10px;">
                           <!-- Buttons here -->
                           <input type="button" class="btn btn-primary save_form" value="Save" />
                           <!--input type="button" class="btn btn-primary reset" value="Reset" /-->
                    </div>
                </div>
                <script>
                        setActivNav("forms");
                </script>